package com.groupbuying.file.service.impl;

import com.groupbuying.file.constants.CommonConstants;
import com.groupbuying.file.controller.FileController;
import com.groupbuying.file.dao.OssFileDao;
import com.groupbuying.file.domain.OssFileDO;
import com.groupbuying.file.pojo.BaseEnum;
import com.groupbuying.file.service.OssFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class OssFileServiceImpl implements OssFileService {

    private static Logger log = LoggerFactory.getLogger(OssFileServiceImpl.class);

    @Autowired
    private OssFileDao ossFileDao;

    @Override
    public OssFileDO get(String uuid) {
        return ossFileDao.get(uuid);
    }

    @Override
    public List<OssFileDO> list(Map<String, Object> map) {
        return ossFileDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return ossFileDao.count(map);
    }

    @Override
    public int save(OssFileDO ossFile) {
        return ossFileDao.save(ossFile);
    }

    @Override
    public int update(OssFileDO ossFile) {
        return ossFileDao.update(ossFile);
    }

    @Override
    public int remove(String uuid) {
        return ossFileDao.remove(uuid);
    }

    @Override
    public int batchRemove(String[] uuids) {
        return ossFileDao.batchRemove(uuids);
    }

    @Override
    public int batchAdd(List<OssFileDO> lsFile) {
        return ossFileDao.batchAdd(lsFile);
    }

    @Override
    public List<OssFileDO> queryByFileGroupCode(String fileKey) {
        log.error("文件系统查找");
        Map<String, Object> map = new HashMap<>();
        map.put("delflag", CommonConstants.COMMON_FLAG_UNDEL);
        map.put("filegroupcode", fileKey);
        map.put("sort","uuid");
        map.put("order","asc");
        List<OssFileDO> list = this.list(map);
        return list;
    }

}
